#pragma once

#include <glad/glad.h> // for OpenGL

#include <string>
#include <fstream>
#include <sstream>
#include <iostream>

class Shader
{
public:
	// programe id
	unsigned int ID;

	Shader(const char *vertexPath, const char *fragmentPath);
	// active programe
	void use();
	// uniform helpers
	void setBool(const std::string &name, bool value) const;
	void setInt(const std::string& name, int value) const;
	void setFloat(const std::string& name, float value) const;

private:
	void checkCompileErrors(unsigned int shader, std::string type)
	{
		int success;
		char infoLog[512];
		if (type == "PROGRAM") {
			glGetShaderiv(shader, GL_LINK_STATUS, &success);
			if (!success) {
				glGetShaderInfoLog(shader, sizeof(infoLog), NULL, infoLog);
				std::cout << "ERROR::PROGRAM_LINKING_ERROR of type: " << type << "\n" << infoLog 
					<< "\n -------------------------------------------------------" << std::endl;
			}
		}
		else {
			glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
			if (!success) {
				glGetShaderInfoLog(shader, sizeof(infoLog), NULL, infoLog);
				std::cout << "ERROR::SHADER_COMPILATION_ERROR of type: " << type << "\n" << infoLog 
					<< "\n -------------------------------------------------------" << std::endl;
			}
		}
	}
};
